<!DOCTYPE html>
<html>

<head>
    <title>{$data['title']|default="帖子详情"}</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content=" ">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/public/static/libs/weui/lib/mui.min.css"/>
    <link rel="stylesheet" href="/public/static/libs/weui/lib/weui.min.css">
    <link rel="stylesheet" href="/public/static/topic/css/jquery-weui.css">
    <link rel="stylesheet" href="/public/static/topic/css/style.css"/>
    <link rel="stylesheet" href="/public/static/libs/weui/lib/preview.css">
</head>
<script src="/public/static/libs/weui/lib/jquery-2.1.4.js"></script>
<script src="/public/static/libs/lazy-load-img/lazy-load-img.min.js"></script>
<script src="/public/static/libs/weui/jquery-weui.js"></script>

<style type="text/css">
    * {
        -moz-user-select: none;
        -moz-user-select: text;
        -moz-user-select: all;

        -webkit-user-select: none;
        -webkit-user-select: text;

        -ms-user-select: none;
        -ms-user-select: text;
        -ms-user-select: element;
    }
    div{
        -moz-user-select: none;
        -moz-user-select: text;

        -webkit-user-select: none;
        -webkit-user-select: text;

        -ms-user-select: none;
        -ms-user-select: text;
        -ms-user-select: element;
    }
    p{
        -moz-user-select: none;
        -moz-user-select: text;

        -webkit-user-select: none;
        -webkit-user-select: text;

        -ms-user-select: none;
        -ms-user-select: text;
        -ms-user-select: element;
    }

    h3{
        -moz-user-select: none;
        -moz-user-select: text;
        -moz-user-select: all;

        -webkit-user-select: none;
        -webkit-user-select: text;

        -ms-user-select: none;
        -ms-user-select: text;
        -ms-user-select: all;
        -ms-user-select: element;}

    span{
        -moz-user-select: none;
        -moz-user-select: text;

        -webkit-user-select: none;
        -webkit-user-select: text;

        -ms-user-select: none;
        -ms-user-select: text;
        -ms-user-select: element;
    }


    body {
        max-width: 100%;

        background: #fff !important;
    }

    .mui-content {
        background: #fff;
    }
    /*.send_detail{margin-top: 1rem;}*/

    .send_detail .head-img {
        overflow: hidden;
        padding: 0 .5rem;
        height: 1.8rem;
    }

    .send_detail .head-img > img {
        float: left;
        width: 1.8rem;
        height: 1.8rem;
        border-radius: 1rem;
    }

    .send_detail .head-info {
        width: 80%
    }

    .send_detail .head-info p:first-of-type {
        height: 1rem;
        line-height: 1rem;
        font-size: .7rem;
        color: #222;
    }

    .send_detail .head_icon {
        float: right;
        margin-left: 10px
    }

    .send_detail .head_icon img {
        width: 20px;
        height: 20px;
        vertical-align: middle;
    }

    .send_detail .news_zixun {
        padding: 0 .5rem;
        border-bottom: 1px solid #eee;
        /*margin-bottom: .5rem;*/
    }

    .send_detail .news_zixun .news_zixun_title {
        height: auto;
        color: #555;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        /*-webkit-line-clamp: 2;*/
        overflow: hidden;
        font-size: 0.8rem;
        margin: .5rem 0;
        -ms-word-wrap:;
        word-wrap: break-word;
    }

    .send_detail .news_zixun .news_zixun_img {
        overflow: hidden;
    }

    .send_detail .news_zixun .news_zixun_img img {
        float: left;
        width: 31.6%;
        /*height: 80px;*/
        margin-right: 2.6%;
        margin-bottom: .5rem;
    }

    .send_detail .news_zixun .news_zixun_img img:nth-of-type(3n) {
        margin-right: 0px;
    }

    .send_detail .bg_bar {
        width: 100%;
        height: .5rem;
        background: #f4f4f4;
    }

    .topic_tle {
        padding: 0.5rem;
        font-size: 1rem;
    }

    .score_width {
        width: 160px;
    }

    .floor {
        color: #5A5A5A;
        font-size: 12px;
        /*margin-left: 2rem;*/
    }

    .edit {
        display: inline-block;
        height: 26px;
        overflow: hidden;
        float: right;
    }

    .edit img {
        width: 26px;
        height: 26px;
        float: left;
        margin-top: 5px;
    }

    .score {
        float: left;
    }

    .get_score_desc {
        font-size: 12px;
    }

    .get_score_desc span:nth-of-type(1) {
        margin-right: 5px;
    }

    .get_score_body {
        overflow: hidden;
        padding-top: .3rem;
    }

    .get_score {
        padding: .5rem;
    }

    .score_box {
        float: left;
        overflow: hidden;
        /*width: 8rem;*/
        height: 1.8rem;
    }

    .score_box img {
        border-radius: 18px;
    }

    .right_commen {
        float: right;
        position: relative;
    }

    .right_commen:after {
        content: '';
        height: 30px;
        width: 3px;
        background: #ddd;
        position: absolute;
        left: -8px;
        top: 5px;
        border-radius: 1.5px;
    }

    .replay {
        background: #ddd;
        color: #5A5A5A;
    }

    .comments{font-size: .8rem;}
    .comments img {
        width: 31.6%;
        margin-right: 2.6%;
        float: left;
        height: 60px;
    }

    .comments img:nth-of-type(3n) {
        margin-right: 0;
    }

    .comment-content .emotion {
        width: 1rem;
        height: 1rem
    }

    blockquote {
        background-color: #efebe9;
        padding: 5px;
        border-radius: 5px;
        font-size: 15px;
    }

    blockquote font font {
        display: block;
    }

    .show_score {
        float: left;
        display: inline-block;
    }

    .jifen {
        box-shadow: 0 0 1px #d81e06;
        height: 1rem;
        width: 3rem;
        overflow: hidden;
        margin-top: .4rem;
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        font-size: 12px;
        border-radius: 3px;
        margin-left: 10px;
        color: #D81E06;
    }

    .jifen img {
        width: .7rem;
        height: .7rem;
        vertical-align: middle;
        margin-right: 2px;
    }
    .mui-popup-text{text-align: center;text-indent: 2em;.}
    .reason{margin-top: 5px;}
    textarea{padding: 0px;height: 50px;font-size: 14px}
    .mui-popup-text{text-indent: 0em;}
    .reason_tip{margin: 10px 0;color: #000;text-align: left;text-indent: 2em;}
    .weui-loadmore__tips{color: #a5a5a5;}
    .reward_box{
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        flex-wrap: wrap;
    }
    .reward_box span{
        display: block;

        color: #5a5a5a;
        font-size: 16px;
        border:1px solid #ff0000;
        border-radius: 5px;
        width: 30%;
        margin-bottom: .5rem;
    }
    .reward_check{
        background: #ff0000;
        color: #fff!important;
        border: none!important;
    }
    .money-change{width: 100%;}
    .hidemoney{display: none;margin: 0!important;}
    #reword{
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-content: center;
        align-items: center;
    }

    .award{
        text-align: center;
        width: 3rem;
        height: 3rem;
        line-height: 3rem;
        border-radius: 1.5rem;
        background:#ff0000;
        color: #fff;
        font-weight: bold;
        font-size: 20px;
        box-shadow:0 0 10px #ff0000;
        margin: .5rem 0;
    }
    .sort_comment{padding: 0 .5rem;height: 2rem;line-height: 2rem;display: flex;flex-direction: row;justify-content: space-between;}
	.sort_comment span{font-size: 16px;color: #5a5a5a;}
</style>

<body>
<!-- body 顶部加上如下代码 -->
<div class="send_detail">
    <div class="topic_tle">{$data['title']}</div>
    <div class="head-img">
        <img src="{$data['avatar']}" data-id="{$data['uid']}" class="avatar-img">
        <div class="head-info">
            <p>{$data['username']}</p>
            <p>
                <span>{$data['ctime']}</span>
                <span class="head_icon"><img
                        src="/public/static/topic/img/commen.png"> {$data['pcounts']}</span>
                <span class="head_icon"><img
                        src="/public/static/topic/img/read.png"> {$data['readcount']}</span>
            </p>
        </div>
    </div>

    <div class="send_box">
        <div class="news_zixun">
            <p class="news_zixun_title">{$data['content']}</p>
            {notempty name="data['pics']"}
            <div class="news_zixun_img">
                {volist name="data['pics']" id="vo"}
                <img class="lazy" data-lazyload="{$vo}" data-preview-src="{php}echo strtr($vo,['/thumb/'=>'/']){/php}" data-preview-group="1" src="/public/static/libs/lazy-load-img/default.png">
                {/volist}
            </div>
            {/notempty}
        </div>
        <!--<div class="bg_bar"></div>-->

    </div>
</div>

<div id="reword">
    <div class="award">
        赏
    </div>
    <p>已有1人打赏作者</p>
</div>

<div class="get_score">
    {notempty name="data['reward']['userList']"}
    <p class="get_score_desc">
        <span>{$data['reward']['userNumber']}人评价</span><span>共{$data['reward']['score'][0]['value']}财富</span>
    </p>
    {/notempty}
    <div class="get_score_body">
        <div class="score">
            {notempty name="data['ratelist']"}
            <div class="score_box">
                {volist name="data['ratelist']['user_arr']" id="vo"}
                <img src="{$vo['avatar']}" width="36" height="36" class="avatar-img" data-id="{$vo['uid']}">
                {/volist}
            </div>
            <img src="/public/static/topic/img/more.png" width="36" height="36" id="get-more"
                 data-href="{:config('website_domain')}{:url('topic/topic_post/score',['pid'=>$data['id']])}">
            {else/}
            <p>内容不错就评个分吧！</p>
            {/notempty}
        </div>
        <div class="right_commen add_score" data-uid="{$data['authorid']}" data-score="{$data['remain_credit']['userful']|default=0}"
             data-pid="{$data['id']}" data-min="{$data['remain_credit']['lowest']}" data-max="{$data['remain_credit']['highest']}"  data-used="{$data['remain_credit']['used']}">
            <img src="/public/static/topic/img/score.png" width="36" height="36">
        </div>
    </div>
</div>
<div style="height: .5rem;width: 100%;background: #F4F4F4;"></div>

<div class="comment-box">
	<div class="sort_comment">
		<span>全部评论</span>
		<span class="select_sort">倒序</span>
	</div>
    {notempty name="data['comment']"}
    {volist name="data['comment']" id="vo"}
    <div class="comment">
        <div class="avtar"><img src="{$vo['useravatar']}" width="36" height="36" class="avatar-img" data-id="{$vo['uid']}"></div>
        <div class="comment-content">
            <p class="avtar-name"><span>{$vo['username']}</span>
                <span class="floor" id="{php}echo strtr($vo['floor'],['楼'=>'']);{/php}">{$vo['floor']}</span>
                <!--<span class="floor"></span>-->
                {if condition="$vo['credit_sum'] gt 0"}
                <span class="show_score"><a href="javascript:;" class="jifen" data-pid="{$vo['id']}"><img
                        src="/public/static/topic/img/jifen.png">{$vo['credit_sum']}财富</a></span>
                {/if}
                <span class="edit edit-comment" data-uid="{$vo['uid']}"  data-pid="{$vo['id']}" data-edit="{$vo['edit_url']}" data-del="{$vo['del_url']}"  data-score="{$vo['credit']['userful']|default=0}"
                      data-min="{$vo['credit']['lowest']}" data-comment="1" data-max="{$vo['credit']['highest']}"  data-used="{$vo['credit']['used']}"><img
                        src="/public/static/topic/img/edit.png"></span></p>
            {if condition="empty($vo['managePanel']) eq false"}
            <!--<span class="edit edit-comment" data-edit="{$vo['managePanel'][0]['action']}" data-del="{$vo['managePanel'][1]['action']}"><img src="/public/static/topic/img/edit.png"></span></p>-->
            {/if}
            </p>
            <p class="comments comment-content">{$vo['content']}</p>
            {notempty name="vo['pic']"}
            <p class="comments">
                {volist name="vo['pic']" id="v"}
                <img class="lazy" data-lazyload="{$v}" data-preview-src="" data-preview-group="1" src="/public/static/libs/lazy-load-img/default.png">
                {/volist}
            </p>
            {/notempty}
            {if condition="$vo['is_quote'] eq 1"}
            <div class="replay" style="font-size: small">
                {php}
                echo str_replace(array("\r\n", "\r", "\n"), "<br>", $vo['quote_content']);
                {/php}
            </div>
            {/if}
            <p class="comment-time"><span>{$vo['ctime']}</span> · <span data-id="{$vo['id']}" class="add_comment"  data-tid="{$vo['tid']}" data-pid="{$vo['pid']}">回复> </span>
            </p>
        </div>
    </div>
    {/volist}
    {/notempty}
</div>


<div id="sheet1" class="mui-popover mui-popover-bottom mui-popover-action ">

    <!-- 可选择菜单 -->
    <ul class="mui-table-view">
        <li class="mui-table-view-cell">
            <a href="#" id="edit_comment">编辑评论</a>
        </li>
        <li class="mui-table-view-cell">
            <a href="javascript:;" id="del_comment">删除评论</a>
        </li>
        <li class="mui-table-view-cell">
            <a href="javascript:;" id="review" class="add_score" data-score="{$remain_score|default=0}">评分</a>
        </li>
    </ul>
    <!-- 取消菜单 -->
    <ul class="mui-table-view">
        <li class="mui-table-view-cell">
            <a href="#sheet1"><b>取消</b></a>
        </li>
    </ul>
</div>

<!--评分开始-->
<div class="mui-popup mui-popup-in pingfen" style="display: none;">
    <div class="mui-popup-inner">
        <div class="mui-popup-title">评分</div>
        <div class="mui-popup-text"></div>
        <div class="mui-popup-input">
            <input type="text" autofocus="autofocus" placeholder="请输入您的评论分数" class="sore">
            <span style="text-align: right" class="rand_word">随机一句</span>
            <textarea autofocus="" placeholder="输入您的评分理由" class="reason"></textarea>
            <input type="hidden" name="remain_score" value="">
            <input type="hidden" name="min" value="">
            <input type="hidden" name="max" value="">
            <input type="hidden" name="used" value="">
            <input type="hidden" name="pid" value="">
            <input type="hidden" name="to_uid" value="">
            <input type="hidden" name="comment" value="">
        </div>
    </div>
    <div class="mui-popup-buttons"> <span class="mui-popup-button cancel">取消</span><span class="mui-popup-button mui-popup-button-bold sure">确定</span>

    </div>
</div>
<!--评分结束-->

<!--打赏开始-->
<div class="mui-popup mui-popup-in reward" style="display: none;">
    <div class="mui-popup-inner">
        <div class="mui-popup-title">打赏</div>
        <div class="mui-popup-text" style="text-align: left;">您的打赏，会支撑我们提供更加优质的内容</div>
        <div class="mui-popup-input reward_box">
            <span data-money="1">1海川币</span>
            <span data-money="5">5海川币</span>
            <span data-money="10">10海川币</span>
            <span data-money="20">20海川币</span>
            <span data-money="50">50海川币</span>
            <span class="other-charge" data-money="">其他</span>

            <div class="money-change">
                <input class="mui-input-numbox mui-input-row hidemoney" type="text" placeholder="自定义金额"  onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');" />
                <!--<p><span class="yuan">0.00</span>元</p>-->
            </div>
        </div>
    </div>
    <div class="mui-popup-buttons">
        <span class="mui-popup-button reward_cancel">取消</span>
        <span class="mui-popup-button mui-popup-button-bold reward_sure">确定</span>
    </div>
</div>


<!--打赏结束-->

<div class="mui-popup-backdrop mui-active" style="display: none;"></div>
<!--上拉加载-->
<div class="weui-loadmore">
    <i class="weui-loading"></i>
    <span class="weui-loadmore__tips">正在加载</span>
</div>
<!--上拉加载解暑-->
<script src="/public/static/libs/weui/lib/fastclick.js"></script>
<script type="text/javascript" src="/public/static/libs/mui/mui-3.4.0/dist/js/mui.js"></script>
<script type="text/javascript" src="/public/static/libs/weui/lib/mui.previewimage.js"></script>
<script type="text/javascript" src="/public/static/libs/weui/lib/mui.zoom.js"></script>
<!--<script type="text/javascript" src="/public/static/libs/weui/js/jquery-weui.js"></script>-->

</body>
<script type="text/javascript">
//初始化
mui.init();
var page = 1;
var storage=window.localStorage;  

    //打赏js
var pid="{$data['id']}";
var tid="{$data['tid']}";
var authorid="{$data['authorid']}";
var uid="{$uid}";
    //选择金额
    mui('body').on('tap', '.reward_box span', function() {
        $(this).addClass('reward_check').siblings().removeClass('reward_check');
        var money=$(this).data('money');
        $('.money-change input').hide();
        $('.hidemoney').val('');
    });

    //自选金额
    mui('body').on('tap', '.other-charge', function() {
        $('.money-change input').show();
        var mon=$('.reward_check').data('');
    });

    //取消打赏
    mui('body').on('tap', '.reward_cancel', function() {
        $('.reward').css('display', 'none');
        $('.mui-popup-backdrop').css('display', 'none');

    });

    //打赏事件弹出
    mui('body').on('tap', '.award', function() {
        $('.reward').css('display', 'block');
        $('.mui-popup-backdrop').css('display', 'block');

    });


    //确定打赏
    mui('body').on('tap', '.reward_sure', function() {
        var mon=$('.reward_check').data('money');
        var t_money=$('.hidemoney').val();
        var money=mon==''?t_money:mon;
        console.log(mon);
        console.log(t_money);
        var s1='您的充值额为'+mon;
        var s2='您的充值额为'+t_money;

        if( t_money=='' && mon==undefined){
            $('.reward').css('display', 'none');
            mui.alert('不能为空',function(){
                $('.reward').css('display', 'block');
            });
            return false;
        }

        if( t_money=='' && mon==''){
            $('.reward').css('display', 'none');
            mui.alert('不能为空',function(){
                $('.reward').css('display', 'block');
            });
            return false;
        }


/*        if(mon=='' && t_money!=''){
            $('.reward').css('display', 'none');
            mui.alert(s2,function(){
                $('.mui-popup-backdrop').css('display', 'none');
            });
        }

        if(mon!='' && t_money==''){
            $('.reward').css('display', 'none');
            mui.alert(s1,function(){
                $('.mui-popup-backdrop').css('display', 'none');
            })
        }*/

        mui.post('/index.php/topic/topic_post/reward', {
            uid: uid,
            pid: pid,
            score: money,
            tid: tid,
            to_uid:authorid
//            reason:reason
        }, function (e) {
            $('.reward').css('display', 'none');
            mui.alert(e.msg, function () {
                if(e.code==200){
//                    window.location.reload();
                    $('.mui-popup-backdrop').css('display', 'none');
                }else{
                    $('.reward').css('display', 'block');
                }
            });
        }, 'json');

    });




    FastClick.attach(document.body);
    function comment(comment_id, tid, pid) {
        var ua = navigator.userAgent.toLowerCase();
        if (/iphone|ipad|ipod/.test(ua)) {
            add_comment(comment_id, tid, pid);
        } else {
            topics.add_comment(comment_id, tid, pid);
        }
    }
    function go_pages(url, title) {
        var ua = navigator.userAgent.toLowerCase();
        if (/iphone|ipad|ipod/.test(ua)) {
            go_urls(url, title);
        } else {
            topic.go_url(url, title);
        }
    }
    function go_page(url, title) {
        var ua = navigator.userAgent.toLowerCase();
        if (/iphone|ipad|ipod/.test(ua)) {
            go_url(url, title);
        } else {
            topic.go_url(url, title);
        }
    }
    function back() {
        var ua = navigator.userAgent.toLowerCase();
        if (/iphone|ipad|ipod/.test(ua)) {
            back_page();
        } else {
            viewPage.back_page();
        }
    }

   
    //懒加载参数设置
    var lazyLoadImg = new LazyLoadImg({
				el: document.querySelector('.news_zixun_img'),
				mode: 'default', //默认模式，将显示原图，diy模式，将自定义剪切，默认剪切居中部分

				time: 300, // 设置一个检测时间间隔

				complete: true, //页面内所有数据图片加载完成后，是否自己销毁程序，true默认销毁，false不销毁

				position: { // 只要其中一个位置符合条件，都会触发加载机制

					top: 0, // 元素距离顶部

					right: 0, // 元素距离右边

					bottom: 0, // 元素距离下面

					left: 0 // 元素距离左边

				},
				before: function() { // 图片加载之前执行方法

				},
				success: function(el) { // 图片加载成功执行方法

					el.classList.add('success')
				},
				error: function(el) { // 图片加载失败执行方法

					el.src = 'http://hc.588net.com/public/static/libs/lazy-load-img/error.png'
				}
			});
			
			
    function getQueryVariable(variable) {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] == variable) {
                return pair[1];
            }
        }
        return (false);
    }
    $(function () {
        var uid="{$uid}";

        //列表图片宽高比例一致
        var send_w = $('.news_zixun .news_zixun_img img').width();
        var score_box = $('.score_box').width();
        $('.news_zixun .news_zixun_img img').height(send_w);

        //评分 人 多于四位  score_box宽度固定
        if (score_box > 150) {
            $('.score_box').addClass('score_width');
        }

        //点击更多  弹出底部
        $('body').on('tap', '.edit-comment', function () {
            console.log($('#del_comment').parent());
            var edit_href = $(this).attr("data-edit");
            var del_href = $(this).attr("data-del");
            var score=$(this).attr("data-score");
            var min=$(this).attr("data-min");
            var max=$(this).attr("data-max");
            var pid=$(this).attr("data-pid");
            var used=$(this).attr("data-used");
            var to_uid=$(this).attr('data-uid');
            var comment=$(this).attr("data-comment");
//            jQuery('#edit_comment').parent().css("display", "none");
//            jQuery('#del_comment').parent().css("display", "none");
            if (edit_href != '') {
                $('#edit_comment').attr({'data-href': edit_href});
            } else {
                $('#edit_comment').parent().css("display", "none");
            }
            if(score){
                $("#review").attr({'data-score':score,'data-min':min,'data-max':max,'data-pid':pid,'data-used':used,'data-comment':comment,'data-uid':to_uid});
            }
            if (del_href != '') {
                $('#del_comment').attr({'data-href': del_href});
            } else {
                $('#del_comment').parent().css("display", "none");
            }
            mui('#sheet1').popover('toggle');
        });
        mui('body').on('tap', '#get-more', function () {
            var url = $(this).attr('data-href');
            go_page(url, '评分列表');
        });
        mui('body').on('tap', '.rand_word', function () {
            var word=["说得真好","不错，赞一个","给力","有才","不错，支持下"];
            var num=parseInt(Math.random()*5);
            console.log(num);
            $('.reason').val(word[num]);
        });
        mui('body').on('tap', '#edit_comment', function () {
            var url=this.getAttribute('data-href');
            mui('#sheet1').popover('toggle');
            go_page(url, '编辑评论');
        });
        mui('body').on('tap', '.add_comment', function () {
            var comment_id=this.getAttribute('data-id');
            var tid=this.getAttribute('data-tid');
            var pid=this.getAttribute('data-pid');
            comment(comment_id, tid, pid)
        });
        mui('body').on('tap', '.avatar-img', function () {
            var user_id=this.getAttribute('data-id');
            var url="{:config('website_domains')}/index.php/topic/friend/user_info/user_id/"+user_id+'/from_uid/'+uid;
            go_page(url,'主页');
        });
        mui('body').on('tap', '#del_comment', function () {
            var href = this.getAttribute("data-href");
            mui('#sheet1').popover('toggle');
            var btnArray = ['取消', '删除'];
            mui.confirm('确认删除？', '提示', btnArray, function(e) {
                if (e.index == 1) {
                    mui.get(href, '', function (result) {
                        if(result.code==200){
                            mui.alert(result.msg,function () {
                                window.location.reload();
                            });
                        }else{
                            mui.alert(result.msg);
                        }
                    }, 'json');
                }
            });
        });
        mui('body').on('tap','a',function () {
            var url=this.getAttribute('href');
            var pid=parseInt(this.getAttribute('data-pid'));
            var id=this.getAttribute("id");
            if(id=="review"){
                return false;
            }
            if(id=='del_comment'){
                return false;
            }
            if(url=='javascript:;' && pid>0){
                var score_url = "{:config('website_domain')}{:url('topic/topic_post/score')}?pid=" + pid;
                go_page(score_url, '评分列表');
                return false;
            }
            if(url.indexOf('forum.php')>=0){
//                url='http://bbs.hcbbs.com/'+url;
                return false;
            }
            console.log(url);
            if(url.indexOf("#")<0){
                console.log(1);
                go_page(url,'');
            }
        });
        //评分
        mui('body').on('tap', '.add_score',function() {
            var remain_score = this.getAttribute('data-score');$('input[name="remain_score"]').val(remain_score);
            var min = this.getAttribute('data-min');$('input[name="min"]').val(min);
            var max = this.getAttribute('data-max');$('input[name="max"]').val(max);
            var used = this.getAttribute('data-used');$('input[name="used"]').val(used);
            var pid = this.getAttribute('data-pid');$('input[name="pid"]').val(pid);
            var to_uid = this.getAttribute('data-uid');$('input[name="to_uid"]').val(to_uid);
            var comment=this.getAttribute('data-comment');$('input[name="comment"]').val(comment);

            if (remain_score == null) {mui.alert("暂无评分权限");return false;}
            var tips='每次评分最多'+max+'，最少'+min+'，今日已使用'+used+'财富，您今日剩余可评' + remain_score + '财富';
            $('.mui-popup-text').text(tips);
            $('#sheet1').hide();
//            add_score(remain_score,min,max,used,pid,to_uid,comment);
            $('.pingfen').css('display','block');
            $('.mui-popup-backdrop').css('display','block');
        });

        //点击取消按钮
        mui('body').on('tap','.cancel',function(){
            var comment=$('input[name="comment"]').val();
            $('.pingfen').css('display','none');
            $('.mui-popup-backdrop').css('display','none');
            if (comment == 1) {
                mui('#sheet1').popover('toggle');
            }
        });
        //点击确定按钮
        mui('body').on('tap','.sure',function(){
            var score=$('.sore').val();
            var reason=$('.reason').val();
            var remain_score = $('input[name="remain_score"]').val();
            var min = $('input[name="min"]').val();
            var max = $('input[name="max"]').val();
            var used = $('input[name="used"]').val();
            var pid = $('input[name="pid"]').val();
            var to_uid = $('input[name="to_uid"]').val();
            var comment=$('input[name="comment"]').val();
            if (score == '') {
                $('.pingfen').css('display','none');
                $('.mui-popup-backdrop').css('display','none');
                mui.alert("请输入评分数",function () {
                    $('.pingfen').css('display','block');
                    $('.mui-popup-backdrop').css('display','block');
                });
                return false;
            }else if(reason==''){
                $('.pingfen').css('display','none');
                $('.mui-popup-backdrop').css('display','none');
                mui.alert("请输入评分理由",function () {
                    $('.pingfen').css('display','block');
                    $('.mui-popup-backdrop').css('display','block');
                });
                return false;
            } else {
                if ((remain_score-score)<0) {
                    $('.pingfen').hide();
                    mui.alert("不得超出剩余评分额度",function(){
                        $('.pingfen').show();
                    });
                } else {
                    var uid="{$uid}";
                    var tid = "{$data['tid']}";
                    mui.post('/index.php/topic/topic_post/score', {
                        uid: uid,
                        pid: pid,
                        score: score,
                        tid: tid,
                        to_uid:to_uid,
                        reason:reason
                    }, function (e) {
                        $('.pingfen').css('display','none');
                        $('.mui-popup-backdrop').css('display','none');
                        mui.alert(e.msg, function () {
                            if(e.code==200){
                                window.location.reload();
                            }
                            $('.sore').val('');
                            $('.reason').val('');
                            $('.mui-backdrop-action').remove();
                        });
                    }, 'json');
                }
            }
        });

       


        function selectText(textbox, startIndex, stopIndex) {
            if (textbox.setSelectionRange) {
                textbox.setSelectionRange(startIndex, stopIndex);
            } else if (textbox.createTextRange) {
                var range = textbox.createTextRange();
                range.collapse(true);
                range.moveStart('character', startIndex);
                range.moveEnd('character', stopIndex - startIndex);
                range.select();
            }
            textbox.focus();
        }


        mui.previewImage();



        function  getData() {
            //业务逻辑代码，比如通过ajax从服务器获取新数据；
            // ......
            //注意：
            //1、加载完新数据后，必须执行如下代码，true表示没有更多数据了：
            //2、若为ajax请求，则需将如下代码放置在处理完ajax响应数据之后;
            $.ajax({
                type: "get",
                url: "/index.php/topic/topic_post_comment/getCommentList?accessSecret={$accessSecret}&accessToken={$accessToken}&id={$id}&tid={$tid}&user_id={$uid}&page=" + page,
                dataType: 'json',
                success: function (e) {
                    if (e.code == 200) {

                        var comment = '';
                        $.each(e.data, function (a, b) {
                            comment += '<div class="comment">';
                            comment += '<div class="avtar"><img src="' + b.useravatar + '" width="36" height="36" class="avatar-img" data-id="'+b['uid']+'"></div>';
                            comment += '<div class="comment-content">';
                            comment += '<p class="avtar-name"><span>' + b.username + '</span>';
                            comment += '<span class="floor" id="' + b.floor.replace('楼', '') + '">' + b.floor + '</span>';
                            //                            comment += '<span class="floor"></span>';
                            if (b.credit_sum > 0) {
                                comment += '<span class="show_score"><a href="javascript:;" class="jifen" data-pid="' + b.id + '"><img src="http://hc.588net.com/public/static/topic/img/jifen.png">' + b.credit_sum + '财富</a></span>';
                            }
                            if (b.managePanel.length > 0) {
                                //comment +='<span class="edit" data-pid='+b.pid+'><img src="img/edit.png"></span>';
                            }
                            comment += '<span class="edit edit-comment"   data-comment="1"  data-uid="'+b['uid']+'" data-edit="' + b.edit_url + '" data-del="' + b.del_url + '" data-score="'+b['credit']['userful']+'"data-pid="'+b['id']+'" data-min="'+b['credit']['lowest']+'" data-max="'+b['credit']['highest']+'"  data-used="'+b['credit']['used']+'"><img src="http://hc.588net.com/public/static/topic/img/edit.png"></span></p>';
                            comment += '</p><p class="comments">' + b.content + '</p>';
                            if(b['pic'].length>0){
                                comment+='<p class="comments">';
                                $.each(b['pic'],function (a,b) {
                                    comment+='<img class="lazy" data-original="'+b+'" data-preview-src="'+b.replace('/thumb/','/')+'" data-preview-group="1">';
                                });
                                comment+='</p>'
                            }
                            comment += '<p class="comment-time"><span>' + b.ctime + '</span> · <span class="add_comment" data-id="' + b.id + '" data-tid="'+b.tid+'" data-pid="'+b.pid+'"">回复> </span></p>';
                            comment += '</div></div>';
                        });
                        $('.comment-box').append(comment);
                       var lazyLoadImg = new LazyLoadImg({
									el: document.querySelector('.comment-box'),
									mode: 'default', //默认模式，将显示原图，diy模式，将自定义剪切，默认剪切居中部分

									time: 300, // 设置一个检测时间间隔

									complete: true, //页面内所有数据图片加载完成后，是否自己销毁程序，true默认销毁，false不销毁

									position: { // 只要其中一个位置符合条件，都会触发加载机制

										top: 0, // 元素距离顶部

										right: 0, // 元素距离右边

										bottom: 0, // 元素距离下面

										left: 0 // 元素距离左边

									},
									before: function() { // 图片加载之前执行方法

									},
									success: function(el) { // 图片加载成功执行方法

										el.classList.add('success')
									},
									error: function(el) { // 图片加载失败执行方法

										el.src = '/public/static/libs/lazy-load-img/error.png'
									}
								});
                        page++;
                    } else {
                        if (e.data.length == 0) {
                            $('.weui-loading').hide();
                            $('.weui-loadmore__tips').text('已加载完毕')
                            $(document.body).destroyInfinite();
                            return false;
                        }
                    }
                }

            });

        }


        $(function () {
            page=1;
            getData();
        })



        //上拉加载
        var loading = false;  //状态标记
        $(document.body).infinite(100).on("infinite", function() {
            if(loading) return;

            getData();
            loading = true;
            console.log('page')
            console.log(page);
            setTimeout(function() {
                loading = false;
            }, 1500);   //模拟延迟

        });
        
        //评论排序
				mui('body').on('tap', '.select_sort', function() {
				
					if($(this).text()=='倒序'){
						storage.setItem("sort",'asc');
						$(this).html('正序');
						getData();
					}else{
						storage.setItem("sort",'desc');
						$(this).html('倒序');
						getData();
					}
				});
		//评论排序结束
    })
</script>

</html>